package threadScheduling;

public class priority {

    public static void main(String[] args) {

        // 分别设置两个线程
        Thread thread1 = new Thread(()->{
           for(int i=0;i<10;i++){
               System.out.println(Thread.currentThread().getName()+"正在输出i:"+i);
               if(i==2){
                   try{
                       Thread.sleep(500);
                   }catch(InterruptedException e){
                       e.printStackTrace();
                   }
               }
           }
        });

        Thread thread2 = new Thread(()->{
           for(int j=0;j<10;j++){
               System.out.println(Thread.currentThread().getName()+"正在输出j:"+j);
               if(j==7){
                   try{
                       Thread.sleep(500);
                   }catch(InterruptedException e){
                       e.printStackTrace();
                   }
               }
           }
        });

// 修改线程优先级
//        thread1.setPriority(Thread.MIN_PRIORITY);
//        thread2.setPriority(8);

        thread1.start();
        thread2.start();
    }
}
